package com.atguigu.springcloud.configuration;

import com.atguigu.springcloud.config.BurnConfig;
import com.atguigu.springcloud.config.RabbitmqConfig;
import com.atguigu.springcloud.config.RabbitmqUtil;
import com.atguigu.springcloud.config.StartRabbitmqConfig;
import com.atguigu.springcloud.service.BurnService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

/**
 * @author xiaolong
 * @version 1.0
 * @description: 总的配置类
 * @date 2021/10/15 17:32
 */
@EnableConfigurationProperties(BurnConfig.class) //使用 @ConfigurationProperties 注解的类生效。
@Import({RabbitmqConfig.class, RabbitmqUtil.class, StartRabbitmqConfig.class})//加载以下类之前会去加载import中的类
@ComponentScan(basePackages = {"com.atguigu.springcloud"})
public class BurnAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(BurnService.class)  //当存在BurnService.class时注入bean
    public BurnService burnService() {
        return new BurnService() {
        };
    }
}
